package com.ruoyi.InboundManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basicData.domain.MaterialManagement;
import com.ruoyi.basicData.service.IMaterialManagementService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.InboundManagement.domain.ProductionEceipt;
import com.ruoyi.InboundManagement.service.IProductionEceiptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产入库管理Controller
 * 
 * @author admin
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/InboundManagement/productionEceipt")
public class ProductionEceiptController extends BaseController
{
    @Autowired
    private IProductionEceiptService productionEceiptService;

    /**
     * 查询生产入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductionEceipt productionEceipt)
    {
        startPage();
        List<ProductionEceipt> list = productionEceiptService.selectProductionEceiptList(productionEceipt);
        return getDataTable(list);
    }

    /**
     * 导出生产入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:export')")
    @Log(title = "生产入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductionEceipt productionEceipt)
    {
        List<ProductionEceipt> list = productionEceiptService.selectProductionEceiptList(productionEceipt);
        ExcelUtil<ProductionEceipt> util = new ExcelUtil<ProductionEceipt>(ProductionEceipt.class);
        util.exportExcel(response, list, "生产入库管理数据");
    }

    /**
     * 获取生产入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:query')")
    @GetMapping(value = "/{eceiptId}")
    public AjaxResult getInfo(@PathVariable("eceiptId") Long eceiptId)
    {
        return success(productionEceiptService.selectProductionEceiptByEceiptId(eceiptId));
    }

    /**
     * 新增生产入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:add')")
    @Log(title = "生产入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductionEceipt productionEceipt)
    {
        return toAjax(productionEceiptService.insertProductionEceipt(productionEceipt));
    }

    /**
     * 修改生产入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:edit')")
    @Log(title = "生产入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductionEceipt productionEceipt)
    {
        return toAjax(productionEceiptService.updateProductionEceipt(productionEceipt));
    }

    /**
     * 删除生产入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:remove')")
    @Log(title = "生产入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eceiptIds}")
    public AjaxResult remove(@PathVariable Long[] eceiptIds)
    {
        return toAjax(productionEceiptService.deleteProductionEceiptByEceiptIds(eceiptIds));
    }






    @PreAuthorize("@ss.hasPermi('InboundManagement:productionEceipt:query')")
    @GetMapping("/Count")
    public AjaxResult selectProductionEceiptCount(ProductionEceipt productionEceipt)
    {
        return success(productionEceiptService.getProductionReceiptCount(productionEceipt));
    }
}
